package edu.gdkm.ssm.dao;

import edu.gdkm.ssm.domain.Product;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 产品信息查询仓储
 */
public interface IProductDao {

    /**
     * 查询所有产品信息
     * @return 所有产品信息
     * @throws Exception
     */
    @Select("select * from product")
    List<Product> findAll() throws Exception;

    /**
     * 添加商品
     * @param product
     */
    @Insert("insert into product(id, productNum, productName, cityName, departureTime, productPrice, " +
            "productDesc, productStatus) values(replace(uuid(), '-', ''), #{productNum}, #{productName}, #{cityName}, #{departureTime}, " +
            "#{productPrice}, #{productDesc}, #{productStatus})")
    void save(Product product);


    /**
     *  根据id查询产品
     */
    @Select("select * from product where id=#{id}")
    Product findById(String id) throws Exception;
}
